package com.youyun.xiaoyuan.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.youyun.xiaoyuan.R;
import com.youyun.xiaoyuan.fragment.LostnFoundFragment;
import com.youyun.xiaoyuan.fragment.SchoolNewsFragment;
import com.youyun.xiaoyuan.fragment.SchoolNoticeFragment;

/**
 * Created by woodnaonly on 2015/12/7.
 */
public class TablayoutFragmentPager extends FragmentPagerAdapter
{
    private  String []titles=null;
    public TablayoutFragmentPager(FragmentManager fm, Context Context)
    {
        super(fm);
        titles=Context.getResources().getStringArray(R.array.tablayouttitle);
    }

    @Override
    public Fragment getItem(int position)
    {
        Fragment mFragment=null;
        switch (position)
        {
            case 0:mFragment=new SchoolNewsFragment();break;
            case 1:mFragment=new SchoolNoticeFragment();break;
            case 2:mFragment=new LostnFoundFragment();break;
        }
        return mFragment;
    }

    @Override
    public int getCount()
    {
        return null==titles?0:titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position)
    {
        return null==titles?null:titles[position];
    }


}
